Skip to content

Repair cross-linked chains and bad directory links under Permissive validation - #97

Merged
mdsteele merged 1 commit into
mdsteele:masterfrom
trypsynth:permissive-repairs
Nov 12, 2026
Merged

mdsteele merged 1 commit into
mdsteele:masterfrom
trypsynth:permissive-repairs

Conversation

@trypsynth

Copy link
Copy Markdown
Contributor

Permissive validation already repairs a FAT entry that points past the end of the file by ending the chain there, but several other spec violations that Word and LibreOffice tolerate were still fatal in both modes. Under Permissive validation this repairs them the same way:

  • A FAT longer than the file is truncated to the file's sectors.
  • A FAT or MiniFAT sector pointed to twice ends the later chain there, so only that chain is truncated.
  • A MiniFAT entry pointing past the end of the MiniFAT ends its chain.
  • A directory entry's sibling or child that is out of range (for example END_OF_CHAIN), or a child on a stream entry, is read as no link.

Strict validation still rejects all of these, and each repair has a _permissive test next to the existing or new _strict one, checking that the repaired result then passes Strict validation.

In a sample of about 2,300 real-world .doc files (Govdocs1 and attachments from the LibreOffice bug tracker), these were the reasons 6 genuine Word documents failed to open: "mini sector 0 pointed to twice" (4 files), "invalid left sibling: 4294967294" and "non-empty stream child". All six open with this change.

…alidation

Permissive validation already repairs a FAT entry that points past the end
of the file by ending the chain there, but several other spec violations
that Word and LibreOffice tolerate were still fatal in both modes. Under
Permissive validation they are now repaired the same way:

- A FAT longer than the file is truncated to the file's sectors.
- A FAT or MiniFAT sector pointed to twice ends the later chain there, so
  only that chain is truncated.
- A MiniFAT entry pointing past the end of the MiniFAT ends its chain.
- A directory entry's sibling or child that is out of range, or a child on
  a stream entry, is read as no link.

Strict validation still rejects all of these. In a sample of about 2,300
real-world .doc files (Govdocs1 and the LibreOffice bug tracker), these
were the reasons 6 genuine Word documents failed to open.
trypsynth added a commit to trypsynth/paperback that referenced this pull request Oct 31, 2026
…hains or bad directory links, through a cfb fork until mdsteele/rust-cfb#97 lands

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mdsteele
mdsteele merged commit a424339 into mdsteele:master Nov 12, 2026
4 checks passed
@mdsteele

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants